package com.dj.mingkong.admin.biz.controller.system;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dj.mingkong.admin.biz.controller.system.vo.request.UserFansQueryVo;
import com.dj.mingkong.admin.biz.controller.system.vo.response.UserFansVo;
import com.dj.mingkong.admin.biz.service.system.UserFansService;
import com.dj.mingkong.common.annotation.HasRoles;
import com.dj.mingkong.common.enums.RoleEnum;
import com.dj.mingkong.common.infrastructure.base.dto.page.PageVo;
import com.dj.mingkong.common.infrastructure.base.dto.rest.RestResponse;
import com.dj.mingkong.common.util.AssertUtils;
import com.dj.mingkong.common.util.SmartBeanCopy;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 用户粉丝管理
 *
 * @author zenglonghui
 * @date: 2022/12/9 11:08
 */
@RestController
@RequestMapping("/user/fans")
@HasRoles(RoleEnum.ADMIN)
public class UserFansController {
    @Resource
    private UserFansService userFansService;

    /**
     * 用户粉丝列表查询
     *
     * @param queryVo {}
     * @return UserFansVo
     */
    @PostMapping("/pageByVo")
    public RestResponse<PageVo<UserFansVo>> pageByVo(@RequestBody UserFansQueryVo queryVo) {
        AssertUtils.checkQueryPageVo(queryVo);
        final Page<UserFansVo> userFansVoPage = userFansService.pageByVo(queryVo);
        final PageVo<UserFansVo> pageVo = SmartBeanCopy.copyPageVo(userFansVoPage, UserFansVo.class);
        return RestResponse.success(pageVo);
    }
}
